﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;

namespace RFIDStockManagement.Client
{
    public class SoundAlert
    {
        SoundPlayer thisPlayer;

        private bool isBeeping;

        public bool IsBeeping
        {
            get { return isBeeping; }
            set { isBeeping = value; }
        }

        public SoundAlert()
        {
            thisPlayer = new SoundPlayer();
            isBeeping = false;
        }

        private string soundPath;

        /// <summary>
        /// 声音文件地址
        /// </summary>
        public string SoundPath
        {
            get { return soundPath; }
            set { soundPath = value; }
        }


        public void Alert()
        {
            if (isBeeping) return;
            if (!System.IO.File.Exists(soundPath))
            {
                return;
            }
            thisPlayer.SoundLocation = soundPath;
            thisPlayer.PlayLooping();
            isBeeping = true;
        }

        public void StopAlert()
        {
            thisPlayer.Stop();
            isBeeping = false;
        }
    }
}
